//
// Created by antler on 2018/12/6.
//
#include "lprefix.h"

#include <new>

#include "Point.h"

#include "log.h"

Point Point::ZERO = Point();
Point Point::INVALID = Point(-1, -1);

Point *Point::create() {
    return new(std::nothrow)Point();
}

Point *Point::createWith(int x, int y) {
    return new(std::nothrow)Point(x, y);
}

Point *Point::createWith(const Point &point) {
    return new(std::nothrow)Point(point);
}

Point::Point() {
    x = 0;
    y = 0;
}

Point::Point(int x, int y) {
    this->x = x;
    this->y = y;
}

Point Point::operator+(const Point &point) const {
    return Point(x + point.x, y + point.y);
}

Point Point::operator-(const Point &point) const {
    return Point(x - point.x, y - point.y);
}

Point Point::operator*(int ratio) const {
    return Point(x * ratio, y * ratio);
}

Point Point::operator/(int ratio) const {
    return Point(x / ratio, y / ratio);
}

bool Point::operator==(const Point &point) const {
    return (x == point.x && y == point.y);
}

Point Point::operator-() const {
    return Point(-x, -y);
}